﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Library;
using System.IO;
using System.Collections;
using System.Data.SqlClient;
namespace QuanLyThi
{
    public partial class FrmDanhSachNganHangCauHoi : Form
    {
        public static string mConnect = FrmMain.mConnect;
        private string msql = "";
        public DGC_Library mLibrary = new DGC_Library(mConnect);


        public FrmDanhSachNganHangCauHoi()
        {
            InitializeComponent();
            LoadMon();
        }
        private void LoadMon()
        {
            msql = "Select b.MS_Mondaotao,b.Mondaotao" +
                     "   from  tb_masodethi a inner join tb_mondaotao b" +
                     "   on a.MS_Mondaotao=b.MS_Mondaotao";
            cmon.DataSource=mLibrary.GetDataTable(msql, "a");
            cmon.DisplayMember = "mondaotao";
            cmon.ValueMember = "ms_mondaotao";
        }

        private void butthoat_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void cmon_SelectionChangeCommitted(object sender, EventArgs e)
        {
            try
            {
                msql = "Select N'Câu hỏi '+Convert(char(3),a.cauhoi) as cauhoi," +
                      "  Case When  b.ChudeCT is null then ''" +
                      "  Else b.ChudeCT " +
                      "  End as ChudeCT, " +
                      "  Case when c.tenmucdo is null then '' " +
                      "  Else c.tenmucdo+' - ' + Convert(char(2),c.Diem)+N' Điểm'" +
                      "  End as Mucdocauhoi," +
                      "  Case When Caubatbuoc=1 then N'Câu bắt buộc'" +
                      "  Else ''" +
                      "  End as Caubatbuoc" +
                      "  from tb_nganhangdethi a left join tb_LoaichudeCT b" +
                      "  on a.ms_chudeCT=b.Ms_chudeCT left join tb_CapdokhoCT c" +
                      "  on a.MS_capdoCT=c.MS_capdoCT" +
                      "  where a.cauhoiID=0" +
                      "  and a.MS_mondaotao=" + cmon.SelectedValue.ToString();
                DataTable dt = mLibrary.GetDataTable(msql, "a");
                dataGridView1.AutoGenerateColumns = false;
                dataGridView1.DataSource = dt;
            }
            catch (Exception)
            {
                
                throw;
            }
        }

       



    }
}
